<?php
define('M_NOUSER',1);
include_once dirname(__FILE__).'/include/general.inc.php';
include_once M_ROOT.'./include/common.fun.php';
include_once M_ROOT.'./include/static.fun.php';
load_cache('sitemaps');
parse_str($_SERVER['QUERY_STRING']);
$map = empty($map) ? 'google' : trim($map);
!($sitemap = $sitemaps[$map]) && mexit('Error sitemap');
empty($sitemap['available']) && mexit('Sitemap closed');
$cachefile = empty($sitemap['xml_url']) ? '' : M_ROOT.$sitemap['xml_url'];
if(empty($sitemap['ttl']) || !$cachefile || ($timestamp - @filemtime($cachefile) > $sitemap['ttl'] * 3600) || !($_mapxml = file2str($cachefile))){
	@extract($btags);
	$tplname = @$sitemap['tpl'];
	$tplname || mexit('No Template');
	$_da = array('ttl' => $sitemap['ttl'],'adminemail' => $adminemail,);
	$_mdebug->setvar('tpl',$tplname);
	$G = array();$_mp = array();
	_aenter($_da,1);
	extract($_da,EXTR_OVERWRITE);
	tpl_refresh($tplname);
	@include M_ROOT."template/$templatedir/pcache/$tplname.php";
	$_mapxml = ob_get_contents();
	ob_clean();
	$_mapxml && $cachefile && str2file($_mapxml,$cachefile);
}
mheader("Content-type: application/xml");
mexit($_mapxml);

?>
